/**
 * 项目名称: Topic_257.cpp
 * 项目路径: study/DataStructure/LeetCode/树/简单
 * 编辑时间: 2024年08月07日15时17分05秒
 * 用   户: 轻尘
 */

#include <bits/stdc++.h>

using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;

    TreeNode() : val(0), left(nullptr), right(nullptr) {}

    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}

    TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), left(left), right(right) {}
};

class Solution {
public:
    vector<string> ans;

    void pre(TreeNode *root, string path) {
        if (root)path = path + to_string(root->val) + "->";
        if (root->left)pre(root->left, path);
        if (root->right)pre(root->right, path);
        if (!root->left && !root->right)
            ans.push_back(path);
    }

    vector<string> binaryTreePaths(TreeNode *root) {
        pre(root,"");
        for(int i = 0;i<ans.size();i++){
            ans[i]=ans[i].substr(0,ans[i].size()-2);
        }
        return ans;
    }
};

int main() {

    return 0;
}
